package com.ikas.ai.server.module.assessment.controller;

import com.github.pagehelper.PageInfo;
import com.ikas.ai.handle.JsonResult;
import com.ikas.ai.model.PageQuery;
import com.ikas.ai.server.module.assessment.model.dto.AwfResultAddDto;
import com.ikas.ai.server.module.assessment.model.dto.AwfResultOfWorkCdDto;
import com.ikas.ai.server.module.assessment.model.dto.AwfResultQueryDto;
import com.ikas.ai.server.module.assessment.service.AssessWfResultService;
import com.ikas.ai.utils.PageExUtil;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 工况模型评价结果管理
 * @menu 工况模型评价结果管理
 * @author wuyf
 * @since 2023-10-31
 */
@RestController
@RequestMapping("/assessment/assessWfResult")
public class AssessWfResultController {

    @Resource
    private AssessWfResultService assessWfResultService;

    /**
     * 评价结果分页查询
     * @param queryDto
     * @param pageQuery
     * @return
     */
    @GetMapping("/page")
    public JsonResult pageAwfResult(AwfResultQueryDto queryDto, PageQuery pageQuery) {
        PageExUtil.configPageHelper(pageQuery);
        return JsonResult.ok(new PageInfo<>(assessWfResultService.listAwfResult(queryDto)));
    }


    /**
     * 评价结果列表查询
     * @param queryDto 入参对象
     * @return list of assessWfResult
     */
    @GetMapping("/list")
    public JsonResult pageAwfResult(AwfResultQueryDto queryDto) {
        return JsonResult.ok(assessWfResultService.listAwfResult(queryDto));
    }

    /**
     * 新增评价结果
     * @param addDto
     * @return
     */
    @PostMapping("/add")
    public JsonResult addAwfResult(@RequestBody AwfResultAddDto addDto) {
        assessWfResultService.addAwfResult(addDto);
        return JsonResult.ok();
    }

    /**
     * 评价结果明细查询
     * @param id 评估结果id
     * @return
     */
    @GetMapping("/detail")
    public JsonResult detailAwfResult(@RequestParam Long id) {
        return assessWfResultService.detailAwfResult(id);
    }

    /**
     * 工况评价结果明细查询
     * @param workCdDto 工况明细参数
     * @return
     */
    @GetMapping("/detailOfWorkCd")
    public JsonResult detailOfWorkCd(@Validated AwfResultOfWorkCdDto workCdDto) {
        return JsonResult.ok(assessWfResultService.detailOfWorkCd(workCdDto));
    }

    /**
     * 通过meteCode获取结果明细条数
     * @param meteCode 测点编码
     * @return Integer
     */
    @GetMapping("/countOfResultDetailByMeteCode")
    public JsonResult countOfResultDetailByMeteCode(@RequestParam String meteCode) {
       return JsonResult.ok(assessWfResultService.countOfResultDetailByMeteCode(meteCode));
    }

    /**
     * 通过meteCode获取结果明细信息
     * @param meteCode 测点编码
     * @return AwfResultDetailCalVo
     */
    @GetMapping("/getResultDetailByMeteCode")
    public JsonResult getResultDetailByMeteCode(@RequestParam String meteCode) {
       return JsonResult.ok(assessWfResultService.getResultDetailByMeteCode(meteCode));
    }
}
